﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;

namespace BSPortal.Usercontrol
{
    public partial class ExportOrder : System.Web.UI.UserControl
    {
        public short OrderId;
        protected void Page_Load(object sender, EventArgs e)
        {
            var mainService = Common.GetClientService();
            var order = mainService.GetOrderById(OrderId);
            lblFee.Text = order.Fee.ToString();
            lblName.Text = order.Name;
            lblAddress.Text = order.Address;
            lblPhone.Text = order.Phone;
            lblStatus.Text = Common.GetOrderStatusString((int)order.Status);

            OnlineShopDataContext dataContext = new OnlineShopDataContext();
            var products = from orderDetail in dataContext.OrderDetails
                          where orderDetail.OrderId == OrderId
                          join product in dataContext.Products
                          on orderDetail.ProductId equals product.ProductId
                          select new { ProductId = product.ProductId, Name = product.Name, Amount = orderDetail.Amount, Distributor = product.Distributor };

            orderRepeater.DataSource = products;
            orderRepeater.DataBind();
        }
    }
}